package main

import "fmt"

//需要利用类型断言
func main() {
	allChan := make(chan interface{}, 10)
	allChan <- &Student{ID: 1, Name: "空条承太郎"}
	stu := <-allChan
	//fmt.Printf("%v", stu.Name) //stu.Name undefined (type interface {} is interface with no methods)
	//必须利用类型断言
	realStu, ok := stu.(*Student)
	if !ok {
		fmt.Println("转换失败")
		return
	}
	fmt.Printf("%v", realStu.Name)

}

type Student struct {
	ID   int32
	Name string
}
